﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using COMOSOFT.Class;
using DevExpress.XtraEditors;
using COMOSOFT.OrderBusiness.Forms;

namespace COMOSOFT.Main
{
    public partial class FrmLogin : Form
    {
        public FrmLogin()
        {
            InitializeComponent();
        }
        int tg = 3;
        FrmMain frmmain;   
        private void btnlogin_Click(object sender, EventArgs e)
        {
            var cls = new ClassShare("FrmLogin");
            if (cls.checklogin(txtaccount.EditValue.ToString(), txtpass.EditValue.ToString()))
            {
                DialogResult = DialogResult.OK;
                txtaccount.EditValue = null;
                txtpass.EditValue = null;
                if (frmmain == null)
                {
                    frmmain = new FrmMain();                 
                }   
                frmmain.TopData();
                frmmain.CheckTabPage();
                frmmain.Show();
                this.Hide();               
            }
        }     
        private void txtaccount_EditValueChanged(object sender, EventArgs e)
        {
            if (txtaccount.EditValue != null && txtpass.EditValue != null)
            {
                btnlogin.Enabled = true;
            }
            else
            {
                btnlogin.Enabled = false;
            }
        }

        private void txtpass_EditValueChanged(object sender, EventArgs e)
        {
            if (txtaccount.EditValue != null && txtpass.EditValue != null)
            {
                btnlogin.Enabled = true;
            }
            else
            {
                btnlogin.Enabled = false;
            }
        }

        private void timer_logon_Tick(object sender, EventArgs e)
        {
            tg--;
            if (tg == 0)
            {
                picture_background.Visible = false;
                timer_logon.Enabled = false;
            }
        }
    }
}
